
package com.kugou.game.sdk.utils;

import com.kugou.game.sdk.core.FolderManager;

import android.content.Context;

import java.io.File;

/**
 * 描述:push相关文件操作
 * 
 * @author allenli
 * @since 2014-8-21 下午3:26:05
 */
public class PushFileUtil {

    static final String PUSH_FILE_NAME = FolderManager.PUSH_FILE_PATH;

    public static void write(Context context, String str) {
        if (!FileUtil.isSDCardAvailable()) {
            return;
        }

        if (!FileUtil.isFileExist(PUSH_FILE_NAME)) {
            FileUtil.createFile(PUSH_FILE_NAME, false);
        }
        FileUtil.writeFile(PUSH_FILE_NAME, str, false);
    }

    public static String read(Context context) {
        if (!FileUtil.isSDCardAvailable()) {
            return null;
        }

        File file = new File(PUSH_FILE_NAME);
        if (!file.exists()) {
            return null;
        } else {
            return FileUtil.readFile(PUSH_FILE_NAME).toString();
        }
    }
}
